# !/usr/bin/env python
# -*- coding:utf-8 -*-
# @FileName  :model.py
# @Time      :2022/8/11 9:27
# @Author    :吕华龙
from flask_sqlalchemy import SQLAlchemy

db = SQLAlchemy()


# 用户模型类
class UserModel(db.Model):
    __tablename__ = "user"
    id = db.Column(db.Integer, primary_key=True, autoincrement=True, comment="ID")
    username = db.Column(db.String(32), comment="用户名称")
    head = db.Column(db.String(128), comment="用户头像")
    personalized = db.Column(db.String(128), comment="个性签名")
    background = db.Column(db.String(256), comment="背景图片")
    circle = db.relationship("CircleModel", backref="user")


# 朋友圈表
class CircleModel(db.Model):
    __tablename__ = "circle"
    id = db.Column(db.Integer, primary_key=True, autoincrement=True, comment="ID")
    circle_content = db.Column(db.String(128), comment="朋友圈内容")
    circle_img = db.Column(db.String(128), comment="朋友圈图片")
    release_time = db.Column(db.DateTime, comment="朋友圈发布时间")
    user_id = db.Column(db.Integer, db.ForeignKey("user.id"), comment="用户ID")


# 好友表
class FriendModel(db.Model):
    __tablename__ = "friend"
    id = db.Column(db.Integer, primary_key=True, autoincrement=True, comment="ID")
    user_id = db.Column(db.Integer, comment="用户id")
    frien_id = db.Column(db.Integer, comment="用户id")
    type = db.Column(db.Integer, comment="状态(0:无权限访问朋友圈，1:有权限访问朋友圈)")
